package TestDemo1;

import java.util.Arrays;

public class Test2 {
    public static void BubbleSort(Comparable[] comparables){
//        NameCompare nameCompare = new NameCompare();
        for (int i = 0; i < comparables.length - 1; i++) {
            for (int j = 0; j < comparables.length - i - 1; j++) {
                if(0 < comparables[j].compareTo(comparables[j + 1])){
                    Comparable temp = comparables[j];
                    comparables[j] = comparables[j+1];
                    comparables[j+1] = temp;
                }
            }
        }
    }
    public static void main(String[] args) {
        Student[] students = new Student[4];
        students[0] = new Student("zhangsan",18,6);
        students[1] = new Student("lisi",17,15);
        students[2] = new Student("wangwu",20,25);
        students[3] = new Student("afei",23,11);
        BubbleSort(students);
        System.out.println(Arrays.toString(students));
    }
}
